package com.robot.backend.utils.email;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
public class registerEmail {

    @Autowired
    codeMaker codeMaker = new codeMaker();
    @Autowired
    JavaMailSender javaMailSender;
    public String sendRegisterEmail( String to ) {
        SimpleMailMessage simpMsg = new SimpleMailMessage();
        String str = codeMaker.kaptchaProducer().createText();
        System.out.println(str);
        simpMsg.setFrom("2631854038@qq.com");
        simpMsg.setTo(to);
        simpMsg.setCc("2631854038@qq.com");
        simpMsg.setSubject("注册验证码");
        simpMsg.setText("您的注册验证码是:   "+str+"   请在五分钟之内完成注册,为了保证您的帐户安全，请勿向任何人提供此验证码。本邮件由系统自动发送，请勿直接回复。");
        System.out.println(simpMsg);
        javaMailSender.send(simpMsg);
        return str;
    }

}
